/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package game.persistence;

import java.io.Serializable;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author raffalli
 */
@Entity
@Table(name = "JOUEUR")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Joueur.findAll", query = "SELECT j FROM Joueur j"),
    @NamedQuery(name = "Joueur.findByPseudo", query = "SELECT j FROM Joueur j WHERE j.pseudo = :pseudo"),
    @NamedQuery(name = "Joueur.findByPassword", query = "SELECT j FROM Joueur j WHERE j.password = :password"),
    @NamedQuery(name = "Joueur.findByEmail", query = "SELECT j FROM Joueur j WHERE j.email = :email"),
    @NamedQuery(name = "Joueur.findByNbPartieWin", query = "SELECT j FROM Joueur j WHERE j.nbPartieWin = :nbPartieWin"),
    @NamedQuery(name = "Joueur.findByNbPartieJoue", query = "SELECT j FROM Joueur j WHERE j.nbPartieJoue = :nbPartieJoue")})
public class Joueur implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 25)
    @Column(name = "PSEUDO")
    private String pseudo;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 25)
    @Column(name = "PASSWORD")
    private String password;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "EMAIL")
    private String email;
    @Basic(optional = false)
    @NotNull
    @Column(name = "NB_PARTIE_WIN")
    private int nbPartieWin;
    @Basic(optional = false)
    @NotNull
    @Column(name = "NB_PARTIE_JOUE")
    private int nbPartieJoue;

    public Joueur() {
    }

    public Joueur(String pseudo) {
        this.pseudo = pseudo;
    }

    public Joueur(String pseudo, String password, String email, int nbPartieWin, int nbPartieJoue) {
        this.pseudo = pseudo;
        this.password = password;
        this.email = email;
        this.nbPartieWin = nbPartieWin;
        this.nbPartieJoue = nbPartieJoue;
    }

    public String getPseudo() {
        return pseudo;
    }

    public void setPseudo(String pseudo) {
        this.pseudo = pseudo;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public int getNbPartieWin() {
        return nbPartieWin;
    }

    public void setNbPartieWin(int nbPartieWin) {
        this.nbPartieWin = nbPartieWin;
    }

    public int getNbPartieJoue() {
        return nbPartieJoue;
    }

    public void setNbPartieJoue(int nbPartieJoue) {
        this.nbPartieJoue = nbPartieJoue;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (pseudo != null ? pseudo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Joueur)) {
            return false;
        }
        Joueur other = (Joueur) object;
        if ((this.pseudo == null && other.pseudo != null) || (this.pseudo != null && !this.pseudo.equals(other.pseudo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "game.persistence.Joueur[ pseudo=" + pseudo + " ]";
    }
    
}
